package de.hsma.srn.interfaces;

import java.util.ArrayList;

import de.hsma.srn.model.account.DomainModel;

public abstract class Controller {
	protected ArrayList<IListener> mListeners;
	
	public Controller() {
		this.mListeners = new ArrayList<IListener>();
	}
	
	public void addListener(IListener listener) {
		if(listener!=null) {
			this.mListeners.add(listener);
		}
	}
	
	public void removeListener(IListener listener) {
		if(this.mListeners.contains(listener)) {
			this.mListeners.remove(listener);
		}
	}
	
	public void notifyListeners(DomainModel domain) {
		for(IListener listener : this.mListeners) {
			listener.update(domain);
		}
	}
}
